﻿namespace ExamV5.GradeInfo
{
    using System;
    using System.Configuration;
    using System.Data;
    using System.Data.SqlClient;
    using System.Web.UI;
    using System.Web.UI.HtmlControls;
    using System.Web.UI.WebControls;

    public class FrmArchiveGradeAN : Page
    {
        protected HtmlForm form1;
        protected HtmlHead Head1;
        protected Label labGradeList;
        protected Label labTitle;
        protected Label labUserCode;
        protected Label labUserDept;
        protected Label labUserEdu;
        protected Label labUserGWName;
        protected Label labUserHand;
        protected Label labUserName;
        protected Label labUserSex;
        protected Label labUserSFZH;
        protected Label labUserWorker;
        private string string_0 = "";
        private string string_1 = "";

        private void method_0()
        {
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select a.UserGWName,a.UserEdu,a.UserSFZH,a.UserCode,a.UserName,a.UserSex,b.DeptName,a.Worker,a.HandCombNO from UserInfo a,DeptInfo b where a.DeptID=b.ID and a.UserCode='" + this.string_0.Trim() + "'", connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            if (reader.Read())
            {
                this.labUserSex.Text = reader["UserSex"].ToString();
                this.labUserDept.Text = reader["DeptName"].ToString();
                this.labUserWorker.Text = reader["Worker"].ToString();
                this.labUserHand.Text = reader["HandCombNO"].ToString();
                this.labUserGWName.Text = reader["UserGWName"].ToString();
                this.labUserEdu.Text = reader["UserEdu"].ToString();
                this.labUserSFZH.Text = reader["UserSFZH"].ToString();
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        private void method_1()
        {
            string str = "";
            SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["Conn"].ConnectionString);
            connection.Open();
            SqlCommand command = new SqlCommand("select UserCode,UserName,ID,SubjectName,ExamName,InputTime,JoinDate,GetCountFen from GradeArchiveFile where UserName='" + this.string_1 + "' and  UserCode='" + this.string_0.Trim() + "' order by ID", connection);
            SqlDataReader reader = command.ExecuteReader(CommandBehavior.CloseConnection);
            while (reader.Read())
            {
                if (!(reader["JoinDate"].ToString() == ""))
                {
                    str = Convert.ToDateTime(reader["JoinDate"]).ToLongDateString();
                }
                else
                {
                    str = Convert.ToDateTime(reader["InputTime"]).ToLongDateString();
                }
                this.labGradeList.Text = this.labGradeList.Text + "<tr height='30'>";
                this.labGradeList.Text = this.labGradeList.Text + "<td><a href='FrmLookArchivePaper.aspx?UserName=" + base.Server.UrlEncode(reader["UserName"].ToString()) + "&UserCode=" + base.Server.UrlEncode(reader["UserCode"].ToString()) + "&ID=" + reader["ID"].ToString() + "' target=_blank>" + reader["ExamName"].ToString() + "</a></td>";
                this.labGradeList.Text = this.labGradeList.Text + "<td>" + reader["SubjectName"].ToString() + "</td>";
                this.labGradeList.Text = this.labGradeList.Text + "<td width='120' align='center'>" + str + "</td>";
                this.labGradeList.Text = this.labGradeList.Text + "<td width='80' align='center'>" + reader["GetCountFen"].ToString() + "分</td>";
                this.labGradeList.Text = this.labGradeList.Text + "<td>&nbsp;</td>";
                this.labGradeList.Text = this.labGradeList.Text + "</tr>";
            }
            reader.Close();
            command.Dispose();
            connection.Close();
            connection.Dispose();
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            this.string_0 = base.Server.UrlDecode(base.Request["UserCode"].ToString());
            this.string_1 = base.Server.UrlDecode(base.Request["UserName"].ToString());
            if (!base.IsPostBack)
            {
                this.labTitle.Text = this.string_1 + "(" + this.string_0 + ")";
                this.Page.Title = ConfigurationManager.ConnectionStrings["ProTitle"].ConnectionString + "--历史成绩档案信息列表";
                this.labUserCode.Text = this.string_0;
                this.labUserName.Text = this.string_1;
                this.method_0();
                this.method_1();
            }
        }
    }
}

